#!/bin/tcsh


### Elapsed time example  
###===================
@ before = `date +%s`
@ after = `date +%s`
@ elapsed_seconds = `expr $after - $before`
@ hh = `expr $elapsed_seconds / 3600`
@ mm = `expr $elapsed_seconds / 60 % 60`
@ ss = `expr $elapsed_seconds % 60`

echo Elapsed time: {$hh}:{$mm}:{$ss} "("$elapsed_seconds "seconds"")"
#cho Elapsed time:$elapsed_seconds seconds
###===================


### while loop, example
###====================
if (! -d TEST) then
mkdir TEST
endif

rm -rf TEST/*

@ n = 4
 while ($n <= 10)
echo now it is {$n}.
if ($n < 10) then
mkdir TEST/set0$n
else
mkdir TEST/set$n
endif

 @ n = ($n + 1)
end
###====================


#!/bin/tcsh

@ argv_num = $#argv

if ($argv_num < 4) then

echo 'usage: make_piv_set_folders.sh . <dir_name> <first#> <last#>'
echo 'For example:'
echo '------------'
echo "make_piv_set_folders.sh . set 1 10"
echo '------------'
echo 'will locally creat <set01> <set02> ... <set10>'
echo " containing <BMP> <IMG> <RESULTS> inside each <set*>"

endif

set loc = $argv[1]
set piv_set_name = $argv[2]
#set first_num = $argv[3]
#set last_num = $argv[4]

cd $loc

@ n = $argv[3]
echo $n
while ($n <= $argv[4])

if ($n < 10) then

mkdir {$piv_set_name}0{$n}
mkdir {$piv_set_name}0{$n}/BMP
mkdir {$piv_set_name}0{$n}/IMG
mkdir {$piv_set_name}0{$n}/RESULTS

echo "Data folder" "piv_set_name0"{$n} "has been created."

else

mkdir $piv_set_name{$n}
mkdir $piv_set_name{$n}/BMP
mkdir $piv_set_name{$n}/IMG
mkdir $piv_set_name{$n}/RESULTS

echo "Data folder" "set"{$n} "has been created."
endif

@ n =($n + 1)

end

###---------- end
